package io.task.cc.network.spi.client;

import io.task.cc.network.ChannelContext;
import io.task.cc.network.Config;
import io.task.cc.network.Handler;
import io.task.cc.network.utils.lock.LockedSet;
import io.task.cc.network.utils.thread.pool.SynThreadPoolExecutor;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

import java.util.HashSet;
import java.util.concurrent.ThreadPoolExecutor;

@Slf4j
@Setter
@Getter
public class ClientConfig extends Config {

    protected ReconnConf reconnConf;//重连配置

    private ConnectionCompletionHandler connectionCompletionHandler = new ConnectionCompletionHandler();

    public final LockedSet<ChannelContext> connecteds = new LockedSet<ChannelContext>(new HashSet<ChannelContext>());
    public final LockedSet<ChannelContext> closeds = new LockedSet<ChannelContext>(new HashSet<ChannelContext>());


    /**
     * @param reconnConf    不用框架自动重连，就传null
     * @param tioExecutor
     * @param groupExecutor
     */
    public ClientConfig(ReconnConf reconnConf, SynThreadPoolExecutor tioExecutor,
                        ThreadPoolExecutor groupExecutor) {
        super(tioExecutor, groupExecutor);


        this.reconnConf = reconnConf;
    }


    @Override
    public Handler getTioHandler() {
        return null;
    }


    /**
     * @return
     * @author tanyaowu
     */
    @Override
    public boolean isServer() {
        return false;
    }

}
